package regex;
/**
 * 字符类规则(参考笔记)
 * [abc]: 匹配a或b或c
 * [^abc]:匹配除了a,b,c以外的所有字符
 * [a-zA-Z]:匹配26个大小写字母之一
 * [a-zA-Z_0-9]:匹配26个大小写字母,数字0-9,以及下划线_
 * [规则]要求字符串只能有一位
 */
public class RegexDemo03 {
    public static void main(String[] args) {
        //method01();
        //method02();
        System.out.println("C".matches("[a-zA-Z]"));//true
        System.out.println("m".matches("[a-zA-Z]"));//true
        System.out.println("_".matches("[a-zA-Z_0-9]"));//true
        System.out.println("3".matches("[a-zA-Z_0-9]"));//true
    }

    private static void method02() {
        System.out.println("a".matches("[^abc]"));
        System.out.println("d".matches("[^abc]"));
        System.out.println(";".matches("[^abc]"));
    }

    private static void method01() {
        System.out.println("a".matches("[abc]"));
        System.out.println("c".matches("[abc]"));
        System.out.println("ab".matches("[abc]"));
        System.out.println("ab".matches("[abc][abc]"));
    }
}
